# Used successfully in Python2.5 with matplotlib 0.91.2 and PyQt4 (and Qt 4.3.3)
from distutils.core import setup
import py2exe

# We need to import the glob module to search for all files.
import glob

# We need to exclude matplotlib backends not being used by this executable.  You may find
# that you need different excludes to create a working executable with your chosen backend.
# We also need to include include various numerix libraries that the other functions call.

opts = {
    'py2exe': { "includes" : [ "matplotlib.backends",  "matplotlib.backends.backend_qt4agg",
                               "matplotlib.figure","pylab", "numpy", "matplotlib.numerix.fft",
                               "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array",
                               "matplotlib.backends.backend_tkagg"],
                'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',
                             '_fltkagg', '_gtk', '_gtkcairo', ],
                'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                 'libgobject-2.0-0.dll']#,'bundle_files': 2,'optimize': 2
              }
       }

## opts = {
##     'py2exe': { "includes" : ["sip", "PyQt4._qt", "matplotlib.backends",  "matplotlib.backends.backend_qt4agg",
##                                "matplotlib.figure","pylab", "numpy", "matplotlib.numerix.fft",
##                                "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array",
##                                "matplotlib.backends.backend_tkagg"],
##                 'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',
##                              '_fltkagg', '_gtk', '_gtkcairo', ],
##                 'dll_excludes': ['libgdk-win32-2.0-0.dll',
##                                  'libgobject-2.0-0.dll']
##               }
##        }

# Save matplotlib-data to mpl-data ( It is located in the matplotlib\mpl-data
# folder and the compiled programs will look for it in \mpl-data
# note: using matplotlib.get_mpldata_info
data_files = [(r'mpl-data', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\*.*')),
                    # Because matplotlibrc does not have an extension, glob does not find it (at least I think that's why)
                    # So add it manually here:
                  (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
                  (r'mpl-data\images',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
                  (r'mpl-data\fonts',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]

# for console program use 'console = [{"script" : "scriptname.py"}]
setup(windows=[{"script" : "formak.py"}], options=opts,   data_files=data_files)


## ** searching for required modules ***
## Traceback (most recent call last):
##   File "setup.py", line 35, in <module>
##     setup(windows=[{"script" : "formak.py"}], options=opts,   data_files=data_fi
## les)
##   File "C:\Python25\lib\distutils\core.py", line 151, in setup
##     dist.run_commands()
##   File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands
##     self.run_command(cmd)
##   File "C:\Python25\lib\distutils\dist.py", line 994, in run_command
##     cmd_obj.run()
##   File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 243, in run
##     self._run()
##   File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 296, in _run
##     self.find_needed_modules(mf, required_files, required_modules)
##   File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 1297, in find_n
## eeded_modules
##     mf.import_hook(mod)
##   File "C:\Python25\Lib\site-packages\py2exe\mf.py", line 719, in import_hook
##     return Base.import_hook(self,name,caller,fromlist,level)
##   File "C:\Python25\Lib\site-packages\py2exe\mf.py", line 136, in import_hook
##     q, tail = self.find_head_package(parent, name)
##   File "C:\Python25\Lib\site-packages\py2exe\mf.py", line 204, in find_head_pack
## age
##     
## ImportError: No module named sip

## D:\python\formak>

